package com.szxy.hyboot.uitls;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class DBUtil {

	private static Properties props;

	static {
		try {
			InputStream in = DBUtil.class.getClassLoader().getResourceAsStream("src/main/resources/application.yml");
			props = new Properties();
			props.load(in);
			in.close();
		}catch(Exception e) {
			e.printStackTrace();
		}
	}

	public static Connection getConn() throws Exception{
		String url = props.getProperty("spring.datasource.url");
		String username = props.getProperty("spring.datasource.username");
		String password = props.getProperty("spring.datasource.password");
		String driver = props.getProperty("spring.datasource.driver-class-name");
		System.out.println(url);
		Class.forName("com.mysql.jdbc.Driver");
		return DriverManager.getConnection("jdbc:mysql://zwer.xyz:3306/miaosha?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
				,"root", "root");
	}

	public static void main(String[] args) throws Exception {
		Connection conn = DBUtil.getConn();
		System.out.println(conn);
	}

}
